<?php	require(dirname(__FILE__).'/include/config.inc.php');
//留言内容处理
if(isset($action) and $action=='add')
{
	if(empty($nickname) or
	   empty($content))
	{
		echo '<script type="text/javascript">alert("留言失败");history.back();</script>';
		exit();
	}


	$r = $dosql->GetOne("SELECT Max(orderid) AS orderid FROM `#@__message`");
	$orderid  = (empty($r['orderid']) ? 1 : ($r['orderid'] + 1));
	$nickname = htmlspecialchars($nickname);
	$contact  = htmlspecialchars($contact);
	$content  = htmlspecialchars($content);
	$posttime = GetMkTime(time());
	$ip       = gethostbyname($_SERVER['REMOTE_ADDR']);


	$sql = "INSERT INTO `#@__message` (siteid, nickname, contact, content, orderid, posttime, htop, rtop, checkinfo, ip) VALUES (1, '$nickname', '$contact', '$content', '$orderid', '$posttime', '', '', 'false', '$ip')";
	if($dosql->ExecNoneQuery($sql))
	{
		$go_url = $_SERVER['HTTP_REFERER'];
		echo '<script type="text/javascript">alert("留言成功");window.location.href="'.$go_url.'";</script>';
		exit();
	}
}
?>